
using Abp.Domain.Repositories;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace SOEI.Solution.DomainEntities.PurQualificationAudit.DomainService
{
    /// <summary>
    /// 领域服务层一个模块的核心业务逻辑
    ///</summary>
    public class PurFamilyMemberManager : DomainServiceBase, IPurFamilyMemberManager
    {

        private readonly IRepository<PurFamilyMember, string> _purfamilymemberRepository;

        /// <summary>
        /// 【PurFamilyMember】的构造方法
        /// 通过构造函数注册服务到依赖注入容器中
        ///</summary>
        public PurFamilyMemberManager(IRepository<PurFamilyMember, string> purfamilymemberRepository)
        {
            _purfamilymemberRepository = purfamilymemberRepository;
        }

        #region -------------------------------------------------辅助工具生成---------------------------------------------- 

        /// <summary>
        /// 返回列表查询用
        /// </summary>
        /// <returns></returns>
        public IQueryable<PurFamilyMember> QueryEntityListAsNoTracking()
        {

            var query = _purfamilymemberRepository.GetAll().AsNoTracking()
                        .Select(x => new PurFamilyMember
                        {

                            Id = x.Id,
                            GFZGSCSQBH = x.GFZGSCSQBH,
                            XM = x.XM,
                            JTCYGXDM = x.JTCYGXDM,
                            ZJLXDM = x.ZJLXDM,
                            ZJHM = x.ZJHM,
                            HKLXDM = x.HKLXDM,
                            SFGFRDM = x.SFGFRDM,
                            SM = x.SM,
                            HJDJRQ = x.HJDJRQ,
                            WSQRDM = x.WSQRDM,
                            LXDH = x.LXDH,
                            LXDZ = x.LXDZ,
                        });
            return query;
        }

        /// <summary>
        /// 【PurFamilyMember】返回表达式数的实体信息即IQueryable类型
        /// </summary>
        /// <returns>IQueryable</returns>
        public IQueryable<PurFamilyMember> Query()
        {
            return _purfamilymemberRepository.GetAll();
        }
        /// <summary>
        /// 【PurFamilyMember】返回即IQueryable类型的实体，不包含EF Core跟踪标记
        /// </summary>
        /// <returns>IQueryable</returns>
        public IQueryable<PurFamilyMember> QueryAsNoTracking()
        {
            return _purfamilymemberRepository.GetAll().AsNoTracking();
        }
        /// <summary>
        /// 【PurFamilyMember】根据Id查询实体信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns>实体</returns>
        public async Task<PurFamilyMember> FindByIdAsync(string id)
        {
            var entity = await _purfamilymemberRepository.GetAsync(id);
            return entity;
        }
        /// <summary>
        /// 【PurFamilyMember】检查实体是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns>bool</returns>
        public async Task<bool> IsExistAsync(string id)
        {
            var result = await _purfamilymemberRepository.GetAll().AnyAsync(a => a.Id == id);
            return result;
        }
        /// <summary>
        /// 【PurFamilyMember】创建实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<PurFamilyMember> CreateAsync(PurFamilyMember entity)
        {
            entity.Id = await _purfamilymemberRepository.InsertAndGetIdAsync(entity);
            return entity;
        }
        /// <summary>
        /// 【PurFamilyMember】更新实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task UpdateAsync(PurFamilyMember entity)
        {
            await _purfamilymemberRepository.UpdateAsync(entity);
        }
        /// <summary>
        /// 【PurFamilyMember】删除实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(string id)
        {
            //TODO:删除前的逻辑判断，是否允许删除
            await _purfamilymemberRepository.DeleteAsync(id);
        }
        /// <summary>
        /// 【PurFamilyMember】批量删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task BatchDelete(List<string> input)
        {
            //TODO:删除前的逻辑判断，是否允许删除
            await _purfamilymemberRepository.DeleteAsync(a => input.Contains(a.Id));
        }
        #endregion


        #region -------------------------------------------------用户自定义------------------------------------------------
        /*请在此扩展领域服务接口*/
        #endregion









    }
}
